home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / csr_001.arc / CSRORDER.C < prev    next >
C/C++ Source or Header  |  1988-09-02  |  18KB  |  451 lines

  1. /*
  2. **  C S R O R D E R . C
  3. **
  4. **  CSR Electronic Order and User Response Form.
  5. **
  6. **  Copyright 1988 Bob Pritchett, New Dimension Software.
  7. **
  8. **  History:
  9. **
  10. **  07/01/88  Registration and mailing list forms added.
  11. **
  12. **  06/11/88  Created and work begun.
  13. **
  14. */
  15.  
  16. #include "color.h"
  17. #include "skey.h"
  18. #include "csrmisc.h"
  19.  
  20. #define VERSION "3.0"            /* Version Number String */
  21.  
  22. #define INTRO    0
  23. #define SURVEY    1
  24. #define REGIS    2
  25. #define PRINT    3
  26. #define THANKS    4
  27. #define MAX    5
  28.  
  29. #define MAXSUR    9
  30.  
  31. extern int _csrclr;            /* Make CSR Global Color Available */
  32.  
  33. void newline(void);            /* Forward Declaration */
  34. void waitkey(void);            /* Forward Declaration */
  35. void text(int);             /* Forward Declaration */
  36. void nameaddr(void);            /* Forward Declaration */
  37. void finddate(void);            /* Forward Declaration */
  38. void info();                /* Forward Declaration */
  39. void survey();                /* Forward Declaration */
  40. void registration();            /* Forward Declaration */
  41. void mailing();             /* Forward Declaration */
  42.  
  43. static char name[40];            /* Name for Response Form */
  44. static char title[40];            /* Title for Response Form */
  45. static char company[40];        /* Company for Response Form */
  46. static char address[40];        /* Address for Response Form */
  47. static char city[40];            /* City for Response Form */
  48. static char state[40];            /* State for Response Form */
  49. static char zip[40];            /* Zip for Response Form */
  50. static char phone[40];            /* Phone for Response Form */
  51. static char compiler[20];        /* Compiler for Response Form */
  52. static char drive[14];            /* Disk Drive for Response Form */
  53.  
  54. static char *sr[MAXSUR][80];        /* Survey Results for Response Form */
  55. static char *survques[MAXSUR] =     /* Survey Questions */
  56.  {
  57.   "Where did you obtain this copy of CSR?  (If from a BBS, please give #.)",
  58.   "How do you use, or intend to use, CSR?",
  59.   "What is the most useful part of the CSR package?",
  60.   "What do you think of the CSR documentation?",
  61.   "If you have seen it, what is your impression of the NDS News?",
  62.   "What is your overall impression of CSR?",
  63.   "Do you work with or plan to work with Microsoft Windows, and how?",
  64.   "Do you work with or plan to work with OS/2 in the near future?",
  65.   "Do you have any other comments?"
  66.  };
  67.  
  68. static int dy;                /* Day */
  69. static int mn;                /* Month */
  70. static int yr;                /* Year */
  71.  
  72. static int w;                /* Work Window */
  73.  
  74. static int ts = 0;            /* Took Survey Flag */
  75. static int bl;                /* Bottom Line Variable */
  76. static int cl = 1;            /* Current Line Counter */
  77.  
  78. main()
  79.  {
  80.   int x;                /* Temporary Variable */
  81.   int cur;                /* Original Cursor Position */
  82.   cur = save_cursor();            /* Save Cursor Position */
  83.   save_screen();            /* Save User's Screen */
  84.   cls();                /* Clear Screen */
  85.   color(WHT_F+RED_B);            /* Set CSR Global Colors */
  86.   scroll(0,0,1,79,0,0,_csrclr);     /* Clear First Two Lines */
  87.   scroll(24,0,24,79,0,0,_csrclr);    /* Clear Last Line */
  88.   /*
  89.   **  The following three lines take advantage of the new ANSI C
  90.   **  adjacent string concatenation and center the text with the
  91.   **  most recently set global color.  This way the above color scheme
  92.   **  can be changed without changing each reference.
  93.   */
  94.   ccenter(0,"C Spot Run v" VERSION ,_csrclr);
  95.   ccenter(1,"User Registration Program",_csrclr);
  96.   ccenter(24,"Copyright 1988 Bob Pritchett, New Dimension Software",_csrclr);
  97.   color(WHT_F+BLU_B);            /* Set CSR Global Colors */
  98.   w = wopen(2,0,23,79,0);        /* Open Borderless Work Window */
  99.   bl = wrow(w)-1;            /* Store Bottom Line */
  100.   wfreeze(w,1,bl);            /* Freeze Top and Bottom Lines */
  101.   whome(w);                /* Home Cursor in Window */
  102.   text(INTRO);                /* Display Introductory Text */
  103.   waitkey();                /* Allow the User to Read the Text */
  104.   nameaddr();                /* Get User's Name and Address */
  105.   info();                /* Obtain Required Information */
  106.   wprint(w,"  Would you please participate in a short survey?");
  107.   x = wfinptynd(w,cl,50,1);        /* Query for Survey */
  108.   newline();                /* Advance the Line Pointer */
  109.   if ( x )                /* If Survey Desired */
  110.      survey();                /* Survey Processing */
  111.   finddate();                /* Check/Obtain Current Date */
  112.   wprint(w,"  Would you like to register as a CSR user?");
  113.   x = wfinptynd(w,cl,44,1);        /* Query for Registration */
  114.   newline();                /* Advance the Line Pointer */
  115.   if ( x )                /* If Registration Desired */
  116.      registration();            /* Registration Processing */
  117.   else                    /* Otherwise */
  118.      mailing();             /* Print Mailing List Application */
  119.   text(THANKS);             /* Display Final Text */
  120.   waitkey();                /* Allow the User to Read the Text */
  121.   wclose(w);                /* Close Work Window */
  122.   restore_screen();            /* Restore the User's Screen */
  123.   restore_cursor(cur);            /* Restore Original Cursor Position */
  124.  }
  125.  
  126. void newline()                /* Advance the Line Count */
  127.  {
  128.   wprint(w,"\n");            /* Perform New Line */
  129.   if ( cl < bl )            /* If Current Line Less Than Bottom */
  130.      ++cl;                /* Increment Current Line Count */
  131.  }
  132.  
  133. void waitkey()                /* Wait for a Keyhit */
  134.  {
  135.   int c;                /* Temporary Character Holder */
  136.   wprint(w,"  -- Hit a Key --");    /* Print Message */
  137.   c = getch();                /* Get a Character */
  138.   if ( ! c )                /* If NULL */
  139.      getch();                /* Get Second Code */
  140.   newline();                /* Advance the Line Count */
  141.  }
  142.  
  143. void text(x)                /* Text Output Routine */
  144.  int x;                 /* ID of Text to Output */
  145.  {
  146.   int i = 0;                /* Temporary Counter */
  147.   static char *info[MAX][16] =        /* Static Array of Text */
  148.    {
  149.     {
  150.      "Thank you for your interest in C Spot Run.  This program is designed",
  151.      "to help you register as a CSR user with a minimum of effort.  With",
  152.      "this program you may order the source code and a usage license, register",
  153.      "as a user, have your name placed on the NDS mailing list, participate",
  154.      "in a survey, or simply comment on the package.",
  155.      "",
  156.      "You will be prompted with a number of questions to which you may respond",
  157.      "by entering a text reply, using a fully editable input field, or by",
  158.      "selecting one of several choices presented in a pop-up menu.",
  159.      "",
  160.      "First, we'll need your name and address.  When you are finished your",
  161.      "input in the pop-up window hit the escape key to continue.",
  162.      "*"
  163.     },
  164.     {
  165.      "The following few questions were chosen to help us understand your",
  166.      "opinion of CSR and to plan for future releases.  Please feel free to",
  167.      "write on the printed form generated by this program if the single line",
  168.      "input field is not enough.",
  169.      "*"
  170.     },
  171.     {
  172.      "Registration for C Spot Run can be done on three levels: Personal or",
  173.      "Commercial Source Code License or simple Shareware Registration.",
  174.      "",
  175.      "A personal source code license entitles an individual to use the",
  176.      "CSR source code for personal use and costs $50.  For $75 a commercial",
  177.      "use license is available; purchase of this license is mandatory for",
  178.      "CSR use in any for-profit setting.  In addition, a $15 registration",
  179.      "option is available which entitles the user to update notifications",
  180.      "but does not include the source code.",
  181.      "",
  182.      "Please select a registration level:",
  183.      "*"
  184.     },
  185.     {
  186.      "Please turn on your printer and line up the top of form.",
  187.      "*"
  188.     },
  189.     {
  190.      "Thank you for your support.  Please send your response form as soon",
  191.      "as possible in order that we may process it quickly.",
  192.      "*"
  193.     }
  194.    };
  195.   if ( x >= MAX )            /* If No Text Available */
  196.      return;                /* Return */
  197.   while ( *info[x][i] != '*' )        /* While Text Remains */
  198.    {
  199.     wprintf(w,"  %s\n",info[x][i++]);    /* Print a Line */
  200.     if ( cl < bl )            /* If Current Line Less Than Bottom */
  201.        ++cl;                /* Increment Current Line Count */
  202.    }
  203.  }
  204.  
  205. void nameaddr()             /* Input Name and Address */
  206.  {
  207.   int lw;
  208.   int x = 0;
  209.   int v;
  210.   wcolor(WHT_F+RED_B,WHT_F+RED_B);
  211.   wfcolor(BLK_F+WHT_B);
  212.   lw = wopen(7,12,15,62,1);
  213.   wtitle(lw,"┤ Name and Address ├",1);
  214.   wmessage(lw,"┤ ESC when Done ├",0);
  215.   wputat(lw,0,4,"Name:");
  216.   wffill(lw,0,10,30);
  217.   wputat(lw,1,3,"Title:");
  218.   wffill(lw,1,10,25);
  219.   wputat(lw,2,1,"Company:");
  220.   wffill(lw,2,10,34);
  221.   wputat(lw,3,1,"Address:");
  222.   wffill(lw,3,10,30);
  223.   wputat(lw,4,4,"City:");
  224.   wffill(lw,4,10,30);
  225.   wputat(lw,5,3,"State:");
  226.   wffill(lw,5,10,2);
  227.   wputat(lw,5,13,"Zip:");
  228.   wffill(lw,5,18,10);
  229.   wputat(lw,6,3,"Phone:");
  230.   wffill(lw,6,10,14);
  231.   while ( 1 )
  232.    {
  233.     switch ( x )
  234.      {
  235.       case 0: v = wfinptstred(lw,0,10,30,name,name);        break;
  236.       case 1: v = wfinptstred(lw,1,10,25,title,title);        break;
  237.       case 2: v = wfinptstred(lw,2,10,34,company,company);    break;
  238.       case 3: v = wfinptstred(lw,3,10,30,address,address);    break;
  239.       case 4: v = wfinptstred(lw,4,10,30,city,city);        break;
  240.       case 5: v = wfinptstred(lw,5,10,2,state,state);        break;
  241.       case 6: v = wfinptstred(lw,5,18,10,zip,zip);        break;
  242.       case 7: v = wfinptstred(lw,6,10,14,phone,phone);        break;
  243.      }
  244.     switch ( v )
  245.      {
  246.       case UARROW: x = max(0,x-1);    break;
  247.       case      1: 
  248.       case DARROW: x = min(7,x+1);    break;
  249.       case   PGUP:
  250.       case   HOME: x = 0;        break;
  251.       case   PGDN:
  252.       case    END: x = 7;        break;
  253.       case     27: x = 100;        break;
  254.       default: x = min(7,x+1);    break;
  255.      }
  256.     if ( x == 100 )
  257.        break;
  258.    }
  259.   wclose(lw);
  260.  }
  261.  
  262. void finddate()             /* Check/Obtain Current Date */
  263.  {
  264.   char temp[80];            /* Temporary String */
  265.   int x;                /* Temporary Variable */
  266.   get_date(&dy,&mn,&yr);        /* Get System Date */
  267.   yr -= 1900;                /* Get Two Digit Year */
  268.   if ( yr > 87 )            /* If Possibly Accurate */
  269.    {
  270.     sprintf(temp,"  The system reports the current date as %02d/%02d/%02d."
  271.         ,mn,dy,yr);
  272.     wprintf(w,temp);            /* Print Current Date */
  273.     newline();                /* Advance the Line Counter */
  274.     wprint(w,"  Is this correct?");    /* Prompt for Verification */
  275.     x = wfinptynd(w,cl,19,1);        /* Verify Date */
  276.     newline();                /* Advance the Line Counter */
  277.     if ( x )                /* If Correct */
  278.        return;                /* Return */
  279.    }
  280.   while ( 1 )                /* Loop Forever */
  281.    {
  282.     wprint(w,"  Please enter the correct date: (01/01/80)");
  283.     wfinptstre(w,cl,44,8,temp);     /* Input Date as String */
  284.     newline();                /* Advance the Line Counter */
  285.     sscanf(temp,"%d/%d/%d",&mn,&dy,&yr);    /* Process Date Entry */
  286.     if ( chk_date(mn,dy,yr) )        /* If Date is Valid */
  287.        break;                /* Break Out */
  288.     wprint(w,"  The date you entered was invalid.");
  289.     newline();                /* Advance the Line Counter */
  290.    }
  291.  }
  292.  
  293. void info()                /* Obtain Required Information */
  294.  {
  295.   int x;                /* Temporary Variable */
  296.   int sc;                /* Saved Cursor Pointer */
  297.   static char *temp[6] =        /* Menu Options */
  298.    {
  299.     "   MSC 5.x   ",
  300.     " Quick C 1.x ",
  301.     "   MSC 4.0   ",
  302.     " Turbo C 1.5 ",
  303.     " Turbo C 1.0 ",
  304.     "    Other    "
  305.    };
  306.   static char *temp2[4] =        /* Second Menu Options */
  307.    {
  308.     " 1.2M 5.25\" ",
  309.     " 360K 5.25\" ",
  310.     "  1.4M 3.5\" ",
  311.     "  720K 3.5\" "
  312.    };
  313.   wprint(w,"  Please select your primary compiler.");
  314.   sc = save_cursor();            /* Save Cursor Position */
  315.   mcolor(WHT_F+RED_B,RED_F+WHT_B);    /* Set Menu Colors */
  316.   x = pop_menu(8,60,6,temp,"┤ Compilers ├",1);    /* Get Menu Choice */
  317.   restore_cursor(sc);            /* Restore Cursor Position */
  318.   newline();                /* Advance the Line Counter */
  319.   strtrm(temp[x],compiler);        /* Store Compiler Name */
  320.   wprint(w,"  Please select your primary disk drive.");
  321.   sc = save_cursor();            /* Save Cursor Position */
  322.   x = pop_menu(9,60,4,temp2,"┤ Drive ├",1);    /* Get Menu Choice */
  323.   restore_cursor(sc);            /* Restore Cursor Position */
  324.   newline();                /* Advance the Line Counter */
  325.   strtrm(temp2[x],drive);        /* Store Drive Type */
  326.  }
  327.  
  328. void survey()                /* Give a User Survey */
  329.  {
  330.   int i;                /* Temporary Variable */
  331.   newline();                /* Advance the Line Counter */
  332.   text(SURVEY);             /* Display Text Regarding Survey */
  333.   newline();                /* Advance the Line Counter */
  334.   for ( i = 0; i < MAXSUR; ++i )    /* Loop Through Questions */
  335.    {
  336.     wprintf(w,"  %s",survques[i]);    /* Print Question */
  337.     newline();                /* Advance the Line Counter */
  338.     wfinptstre(w,cl,4,74,sr[i]);    /* Input String Result */
  339.     newline();                /* Advance the Line Counter */
  340.     newline();                /* Advance the Line Counter */
  341.    }
  342.   wprint(w,"  Thank you.");        /* Thank User for Survey */
  343.   newline();                /* Advance the Line Counter */
  344.   ts = 1;                /* Set Took Survey Flag */
  345.  }
  346.  
  347. void registration()            /* Print Order Form for Registration */
  348.  {
  349.   int x;                /* Temporary Variable */
  350.   int tmp;                /* Temporary Variable */
  351.   char t1[80];                /* Temporary String */
  352.   char t2[80];                /* Temporary String */
  353.   static int amt[3] =            /* Dollar Amounts */
  354.    {
  355.     50, 75, 15
  356.    };
  357.   newline();                /* Advance the Line Counter */
  358.   text(REGIS);                /* Display Registration Description */
  359.   newline();                /* Advance the Line Counter */
  360.   wprint(w,"    1) Personal  2) Commercial  3) Shareware:");
  361.   wfinptintr(w,cl,46,2,&tmp,1,3);    /* Input Choice */
  362.   newline();                /* Advance the Line Counter */
  363.   wprint(w,"  Thank you.");        /* Thank User for Order */
  364.   newline();                /* Advance the Line Counter */
  365.   text(PRINT);                /* Have User Ready Printer */
  366.   waitkey();                /* Wait for a Key */
  367.   strcen("C Spot Run v" VERSION ,t1,78);/* Center String */
  368.   strcen("Order Form",t2,78);        /* Center String */
  369.   lprintf("\n\n %s\n %s\n\n\n",t1,t2);    /* Print Header */
  370.   lprintf("\t\t\t\t\t\t\t\t%02d/%02d/%2d\n",mn,dy,yr);    /* Print Date */
  371.   lprintf("\t%s, ",name);        /* Print User's Name */
  372.   lprintf("%s\n",title);        /* Print User's Title */
  373.   lprintf("\t%s\n",company);        /* Print User's Company */
  374.   lprintf("\t%s\n",address);        /* Print User's Address */
  375.   lprintf("\t%s, %s  %s\n",city,state,zip); /* Print User's City/State/ZIP */
  376.   lprintf("\t%s\n\n",phone);        /* Print User's Phone */
  377.   lprintf("\t%s - %s\n",compiler,drive);/* Print User's Configuration */
  378.   if ( ts )                /* If User Took Survey */
  379.    {
  380.     lprint("\n    -- Survey Results\n");    /* Print Survey Header */
  381.     for ( x = 0; x < MAXSUR; ++x )    /* Loop Through Survey */
  382.      {
  383.       lprintf("    %d> %s\n",x+1,survques[x]);    /* Print Survey Question */
  384.       lprintf("         %s\n",sr[x]);        /* Print Survey Result */
  385.      }
  386.     lprint("\n");
  387.    }
  388.   else                    /* Otherwise */
  389.     for ( x = 0; x < MAXSUR+2 ; ++x )    /* Loop for Survey Lines */
  390.     lprint("\n\n");         /* Print a Newline */
  391.   lprint("\n\n\n\n\t\tPlease enclose a check or money order made out to\n");
  392.   lprintf("\t\tNew Dimension Software for the amount of $%d.\n",amt[tmp-1]);
  393.   lprint("\n\t\tAddress the envelope to:\n\n");
  394.   lprint("\t\t\tNew Dimension Software\n");
  395.   lprint("\t\t\t23 Pawtucket Dr.\n");
  396.   lprint("\t\t\tCherry Hill, NJ  08003\n\n\n\n\n\n");
  397.   lprint("\t    +--------------------  NDS USE ONLY  --------------------+\n");
  398.   lprint("\t    |                                                        |\n");
  399.   lprint("\t    |  Received:  ____ /____ /____   Sent: ____ /____ /____  |\n");
  400.   lprint("\t    |                                                        |\n");
  401.   lprint("\t    |             Serial Number: ________________            |\n");
  402.   lprint("\t    |                                                        |\n");
  403.   lprint("\t    +--------------------------------------------------------+\n");
  404.   lputchar('\f');            /* Print FormFeed */
  405.  }
  406.  
  407. void mailing()                /* Print Mailing List Application */
  408.  {
  409.   int x;                /* Temporary Variable */
  410.   char t1[80];                /* Temporary String */
  411.   char t2[80];                /* Temporary String */
  412.   newline();                /* Advance the Line Counter */
  413.   text(PRINT);                /* Have User Ready Printer */
  414.   waitkey();                /* Wait for a Key */
  415.   strcen("C Spot Run v" VERSION ,t1,78);/* Center String */
  416.   strcen("Mailing List Application",t2,78); /* Center String */
  417.   lprintf("\n\n %s\n %s\n\n\n",t1,t2);    /* Print Header */
  418.   lprintf("\t\t\t\t\t\t\t\t%02d/%02d/%2d\n",mn,dy,yr);    /* Print Date */
  419.   lprintf("\t%s, ",name);        /* Print User's Name */
  420.   lprintf("%s\n",title);        /* Print User's Title */
  421.   lprintf("\t%s\n",company);        /* Print User's Company */
  422.   lprintf("\t%s\n",address);        /* Print User's Address */
  423.   lprintf("\t%s, %s  %s\n",city,state,zip); /* Print User's City/State/ZIP */
  424.   lprintf("\t%s\n\n",phone);        /* Print User's Phone */
  425.   lprintf("\t%s - %s\n",compiler,drive);/* Print User's Configuration */
  426.   lprintf("\n\n\n\n");            /* Space Out Form */
  427.   lprint("                  -------  Fold Outward on this Line  -------\n");
  428.   if ( ts )                /* If User Took Survey */
  429.    {
  430.     lprint("\n    -- Survey Results\n");    /* Print Survey Header */
  431.     for ( x = 0; x < MAXSUR; ++x )    /* Loop Through Survey */
  432.      {
  433.       lprintf("    %d> %s\n",x+1,survques[x]);    /* Print Survey Question */
  434.       lprintf("         %s\n",sr[x]);        /* Print Survey Result */
  435.      }
  436.     lprint("\n");
  437.    }
  438.   else                    /* Otherwise */
  439.     for ( x = 0; x < MAXSUR+2 ; ++x )    /* Loop for Survey Lines */
  440.     lprint("\n\n");         /* Print a Newline */
  441.   lprint("                  -------  Fold Outward on this Line  -------\n\n\n");
  442.   lprint("\t\t\t\t\t\t\t\t\tPlace\n");
  443.   lprint("\t\t\t\t\t\t\t\t\tStamp\n");
  444.   lprint("\t\t\t\t\t\t\t\t\tHere.\n\n\n\n\n\n");
  445.   lprint("\t\t\t\tNew Dimension Software\n");
  446.   lprint("\t\t\t\tMailing List Application\n");
  447.   lprint("\t\t\t\t23 Pawtucket Dr.\n");
  448.   lprint("\t\t\t\tCherry Hill, NJ  08003\n");
  449.   lputchar('\f');            /* Print FormFeed */
  450.  }
  451.